package com.ruoyi.project.ysgj.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.ysgj.domain.HZbk;
import com.ruoyi.project.ysgj.service.IHZbkService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 指标库Controller
 * 
 * @author 菜心
 * @date 2020-07-31
 */
@RestController
@RequestMapping("/ysgj/zbk")
public class HZbkController extends BaseController
{
    @Autowired
    private IHZbkService hZbkService;

    /**
     * 查询指标库列表
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:list')")
    @GetMapping("/list")
    public TableDataInfo list(HZbk hZbk)
    {
        startPage();
        List<HZbk> list = hZbkService.selectHZbkList(hZbk);
        return getDataTable(list);
    }

    /**
     * 导出指标库列表
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:export')")
    @Log(title = "指标库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HZbk hZbk)
    {
        List<HZbk> list = hZbkService.selectHZbkList(hZbk);
        ExcelUtil<HZbk> util = new ExcelUtil<HZbk>(HZbk.class);
        return util.exportExcel(list, "zbk");
    }

    /**
     * 获取指标库详细信息
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(hZbkService.selectHZbkById(id));
    }

    /**
     * 新增指标库
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:add')")
    @Log(title = "指标库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HZbk hZbk)
    {
        return toAjax(hZbkService.insertHZbk(hZbk));
    }

    /**
     * 修改指标库
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:edit')")
    @Log(title = "指标库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HZbk hZbk)
    {
        return toAjax(hZbkService.updateHZbk(hZbk));
    }

    /**
     * 删除指标库
     */
    @PreAuthorize("@ss.hasPermi('ysgj:zbk:remove')")
    @Log(title = "指标库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(hZbkService.deleteHZbkByIds(ids));
    }
}
